home *** CD-ROM | disk | FTP | other *** search
- Path: bessel.nando.net!validatr
- From: validatr@nando.net (validatr)
- Newsgroups: comp.lang.c
- Subject: Re: Infrequent use of do while, C Idioms
- Date: 11 Jan 1996 12:24:26 GMT
- Organization: NandO.net
- Distribution: world
- Message-ID: <4d2vhq$rir@castle.nando.net>
- References: <49slsq$10l@panix2.panix.com> <4a5pk6$pvd@ixnews6.ix.netcom.com> <1995Dec7.154222.9354@lamont.ldgo.columbia.edu> <1996Jan2.150509@hsun13.hou281.chevron.com>
- NNTP-Posting-Host: bessel.nando.net
- X-Newsreader: TIN [version 1.2 PL2]
-
- Actually the do while command is quite useful if you want to execute some
- code at least once and then conditionally. This saves you from writing
- something like:
-
- perform x
- while(condition) {perform x}
-
- which is something we all have seen. It is less code and still
- completely understandable to do the following:
-
- do {perform x} while (condition)
-
- I like the command and have used it frequently.
-
- C.W.Racer (gacwra@hsun13.hou281.chevron.com) wrote:
- : In article <1995Dec7.154222.9354@lamont.ldgo.columbia.edu>, mike@armchair.mb.ca (Mike Forster) writes:
- : |> cjds@ix.netcom.com (Bill Horger) wrote:
- : |>
- : |> [snipped]
- : |>
- : |> >
- : |> >| So, anyhow, I was thinking and I realized that I have never ever seen
- : |> >| a
- : |> >| do {
- : |> >| } while (condition)
- : |> >
- : ---------------------------------stuff deleted -----------------------
-
- : The issue here is do you want the loop 'top-tested' or 'bottom-tested'?
- : Most c programmers prefer (seems to me) the top-tested loop. Once in a
- : while I'll find the other one seems to fit better.
-
- : PL/1 DO loops allow both (using the 'while' and 'until' for top and
- : bottom tested). I actually used that once but only because it intrigued
- : me.
- : --
- : | Chick Racer Chevron Petroleum Technology Co. |
- : | (713) 596-2430 P.O. Box 42832 |
- : | gacwra@chevron.com Houston, Tx 77242-2832 |
- : | 4119 Hayes Rd. |
-
- --
- **************************************************************************
- "In God we trust, all others require documented evidence" Validation Creed
- "If I had known I would live this long, I would have taken better care of
- myself" validatr@nando.net is Bob Whitener, the Validator 0==|======>
-